package com.uuah.server.transport.provider.mina.codecs;

import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

import com.uuah.utils.ClassUtils;

/**
 *
 * TODO comment ...
 *
 * <p>
 * update record:updator，update time，update content and version
 * </p>
 *
 * @author <a href="jonny_quan@hotmail.com">jonny</a>
 * @date 2009 2009-3-27 下午02:10:06
 * @version 1.0.0
 */
public class UuahMessageCodecFactory extends MinaRequestResponseCodecFactory {
	protected String serverEncoderClass = "com.uuah.server.transport.provider.mina.codecs.server.UuahResponseMessageEncoder";
	protected String serverDecoderClass = "com.uuah.server.transport.provider.mina.codecs.server.UuahRequestMessageDecoder";
	protected String clientEncoderClass = "com.uuah.server.transport.provider.mina.codecs.client.UuahRequestMessageEncoder";
	protected String clientDecoderClass = "com.uuah.server.transport.provider.mina.codecs.client.UuahResponseMessageDecoder";

	public UuahMessageCodecFactory(boolean isServer) {
		super(isServer);
	}

	@Override
	protected ProtocolDecoder getClientDecoder() throws Exception {
		return (ProtocolDecoder) ClassUtils.instanciateClass(
				this.clientDecoderClass, null);
	}

	@Override
	protected ProtocolEncoder getClientEncoder() throws Exception {
		return (ProtocolEncoder) ClassUtils.instanciateClass(
				this.serverEncoderClass, null);
	}

	@Override
	protected ProtocolDecoder getServerDecoder() throws Exception {
		return (ProtocolDecoder) ClassUtils.instanciateClass(
				this.serverDecoderClass, null);
	}

	@Override
	protected ProtocolEncoder getServerEncoder() throws Exception {
		return (ProtocolEncoder) ClassUtils.instanciateClass(
				this.serverEncoderClass, null);
	}
}
